
export const useCountdown = (initialValue = 60) => {
    const count = ref(0)
    let timer: NodeJS.Timeout | null = null

    const startCountdown = () => {
        count.value = initialValue
        clearInterval(timer!)
        timer = setInterval(() => {
            count.value--
            if (count.value === 0) {
                clearInterval(timer!)
            }
        }, 1000)
    }

    const stopCountdown = () => {
        count.value = 0
        clearInterval(timer!)
    }

    onUnmounted(() => clearInterval(timer!))

    return {
        count,
        startCountdown,
        stopCountdown
    }
} 